<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
          name="viewport">
    <title>店铺位置</title>
    <link rel="stylesheet" href="../css/base.css">
    <link rel="stylesheet" href="../css/mobile-select-area.css">
    <script src="../js/jquery-1.8.3.min.js"></script>
    <script src="../js/dialog.js"></script>
    <script src="../js/mobile-select-area.js"></script>
    <script src="../js/city.js"></script>
    <script src="../js/public.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=G1TP5IX5FqiWtbqPN8sjmCZYhFpwMq0R"></script>

    <style>
        .footer-btns{
            background: #5f3104;
            color: #fff;
            font-size: 12px;
            text-align: center;
            line-height: 40px;
            position: fixed;
            width: 80%;
            left: 10%;
            right: 10%;
            bottom: 20px;
            border-radius: .04rem;
        }
        .bor{
            border: none;
            width: 100%;
            line-height: 40px;
            padding: 0 10px;
            box-sizing: border-box;
            border-bottom: solid 1px #ddd;
        }
        .dinpu{
            width: 100%;
            height: 40px;
            border: none;
            border-bottom: 1px solid #f2f2f2;
            padding: 0 10px;
        }
    </style>
</head>
<body>
    <div id="divlist">

    </div>
 <!--   <div>
        <input type="text" placeholder="省市区" class="bor" id="shengshiqu">
    </div>
    <div>
        <input type="text" placeholder="请填写详细地址" class="bor" id="address">
    </div>
    -->
    <div class="footer-btns" id="save">
        保存
    </div>
  <!--  <div>
        <input type="text" placeholder="输入您的地址" class="bor" id="shengshiqu">
    </div>-->
    <div id="l-map"></div>
    <div id="r-result"><input type="text" id="suggestId" size="20" value="百度" style="width:100%;border: none;line-height: 40px;padding: 0 10px;box-sizing: border-box" /></div>
    <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    function G(id) {
        return document.getElementById(id);
    }

    // 初始化地图,设置城市和地图级别。

    var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
        {"input" : "suggestId"
        });

    var myValue;
    ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
        var _value = e.item.value;
        myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
    });



</script>
</body>
<script>
//    $(function () {
//        var _address ={};
//        var selectArea2 = new MobileSelectArea();
//        selectArea2.init({
//            position:"bottom",
//            trigger:$('#shengshiqu'),
//            value:$('#shengshiqu').val(),
//            data:json3,
//            callback:function (scroller,text,value){
//                console.log("vals="+value);
//                _address.province = text[0];
//                _address.city = text[1];
//                _address.area = text[2];
//                $("#shengshiqu").val(_address.province+ " "+_address.city+" "+_address.area);
//            }
//        });
//    });
    $("#save").click(function (){
  /*      if(isNull($("#shengshiqu").val())){
            alert("请选择省市区");
            return false;
        }
        if(isNull($("#address").val())){
            alert("请填写详细地址");
            return false;
        }*/
        var  $vals = ($("#suggestId").val()).replace(/\s+/g,"");//删除所有空格;
        if(isNull($vals)){
            alert("请填写您的地址");
            return false;
        }
        console.log($vals);
        $.ajax({
            url:base_url+"ZITAOHUI/store/addstoreAddress",
            data:{
                store_id:sessionStorage.getItem("s_id"),
                address:$vals
            },
            dataType:"json",
            success:function (data){
                if(data.code == 1){
                    alert("保存成功");
                    window.location.href = "dianpuweizhilist.html"
                }
            },
            error:function (error){

            }
        })
    })

</script>
</html>

<!--
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";font-size:14px;}
        #l-map{height:300px;width:100%;}
        #r-result{width:100%;position: absolute;top: 0;}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=G1TP5IX5FqiWtbqPN8sjmCZYhFpwMq0R"></script>
    <title>店铺位置</title>
</head>
<body>
<div id="l-map"></div>
<div id="r-result">请输入:<input type="text" id="suggestId" size="20" value="百度" style="width:150px;" /></div>
<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    function G(id) {
        return document.getElementById(id);
    }

    // 初始化地图,设置城市和地图级别。

    var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
        {"input" : "suggestId"
        });

    var myValue;
    ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
        var _value = e.item.value;
        myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
    });



</script>-->
